package com.yc.mybatis.mapper;

import com.yc.mybatis.entity.Bill;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

/**
 * Company 源辰信息
 *
 * @author navy
 * @date 2024/10/24
 * Email haijunzhou@hnit.edu.cn
 */
public interface BillMapper {

    @Results(
           id = "rm1",
           value = {
                   @Result(id = true, column = "id", property = "id"),   // <id>
                   @Result(column = "id", property = "items",
                   many = @Many(fetchType = FetchType.LAZY,
                   select = "com.yc.mybatis.mapper.BillItemMapper.selectByBid"))
           }
    )
    @Select("select * from bill where type = #{type}")
    List<Bill> selectByType(String type);
}
